package net.cnki.sunny.common;

import lombok.Data;
import org.springframework.http.HttpStatus;

@Data
public class ResultVO<T> {

    private Integer code;

    private String msg;

    private T data;

    public ResultVO() {

    }

    public ResultVO(Integer code, String msg, T data) {
        this.code = code;
        this.msg = msg;
        this.data = data;
    }

    public ResultVO(Integer code, String msg) {
        this.code = code;
        this.msg = msg;
    }

    public ResultVO success() {
        return new ResultVO(HttpStatus.OK.value(),"成功");
    }

    public ResultVO success(T data) {
        return new ResultVO(HttpStatus.OK.value(), "成功", data);
    }

    public ResultVO error(String msg) {
        return new ResultVO(HttpStatus.INTERNAL_SERVER_ERROR.value(), msg);
    }
}
